package ext.tianma.model;

import java.io.Externalizable;

import wt.fc.IdentificationObject;
import wt.fc.Identified;
import wt.util.WTException;
import wt.util.WTPropertyVetoException;

import com.ptc.windchill.annotations.metadata.GenAsUnPersistable;
import com.ptc.windchill.annotations.metadata.GeneratedProperty;
import com.ptc.windchill.annotations.metadata.PropertyConstraints;

@GenAsUnPersistable(superClass = IdentificationObject.class, interfaces = { Externalizable.class },
        properties = { 
        @GeneratedProperty(name = "number", type = String.class, constraints = @PropertyConstraints(upperLimit = 4000)),
        @GeneratedProperty(name = "name", type = String.class, constraints = @PropertyConstraints(upperLimit = 4000))})

public class TMObjectModelMasterIdentity extends _TMObjectModelMasterIdentity {
    static final long serialVersionUID = 1;

    public static TMObjectModelMasterIdentity newTMObjectModelMasterIdentity(String number, String name) throws WTException {
        TMObjectModelMasterIdentity instance = new TMObjectModelMasterIdentity();
        instance.initialize(number, name);
        return instance;
    }

    protected void initialize(String number, String name) throws WTException {
        try {
            setNumber(number);
            setName(name);
        } catch (WTPropertyVetoException wtpve) {
            throw new WTException(wtpve);
        }
    }

    @Override
    protected String getKeyClassName() {
        return TMObjectModelMasterKey.class.getName();
    }

    @Override
    public String getIdentity() {
        return getNumber();
    }

    @Override
    protected void setToObject(Identified obj) throws WTException {
        ((TMObjectModelMaster) obj).setIdentificationObject(this);
    }

}
